#
# Cookbook Name:: om
# Recipe:: install
#
# Copyright 2013, IBM
#
# All rights reserved - Do Not Redistribute
#


wasuser = node[:was][:user]
wasgroup = node[:was][:group]
wasuserpw = node[:was][:userpw]
cuser = node[:chef][:user]
cgroup = node[:chef][:group]
deployment = node[:deployment]


startinstr "Download OM sample"

#include_recipe "common::setup_wasuser"

directory "/tmp/was" do
  user cuser
  action :create
end


bash "Fetch OM files" do
 	user cuser
 	cwd "/tmp/"
 	creates "/tmp/downloadsample.complete"
 	code <<-EOH
		set -x
		mkdir -p /tmp/om/sample
		scp -r #{node[:common][:scp_repo]}/downloads/om/sample/* /tmp/om/sample
		if [ $? == 0 ]; then
			touch /tmp/om/downloadsample.complete
		fi
		set +x
  	EOH
end


bash "Change owner of OM sample" do
	user "root"
	cwd "/tmp/"
	code <<-EOH
        chown -R #{node[:was][:user]}:#{node[:was][:group]} /tmp/om
	EOH
end

stopinstr "Download OM sample"



